import axios from "axios";
const order = {
  state() {
    return {
      list: [],
      page: 1,
      size: 5,
      count: 0,
    };
  },
  getters: {},
  mutations: {
    initList(state, list) {
      state.list = list;
    },
    initCount(state, count) {
      state.count = count;
    },
    updatePage(state, page) {
      state.page = page;
    },
    updateSize(state, size) {
      state.size = size;
    },
  },
  actions: {
    async getOrder(context) {
      const { data: res } = await axios.get("/vip/orders/whole", {
        params: {
          page: context.state.page,
          limit: context.state.size,
        },
      });
      context.commit("initList", res.data);
      context.commit("initCount", res.count);
    },
    async delOrderList(context, e) {
      const { data: res } = await axios.post("/vip/orders/update", {
        id: e,
      });
      console.log(res);
      context.dispatch("getOrder");
    },
  },
  modules: {},
};

export default order;
